/*********************************************************************************
 *Copyright(C),1996-2022,ChenJiehong
 *FileName:  swtimer.h
 *Author:  ChenJiehong
 *Version:  V1.0
 *Date: 2023-04-18
 **********************************************************************************/

#ifndef __swtimer_H__
#define __swtimer_H__

/***************************************Includes***********************************/
#include "stdint.h"
#include "swtimer_conf.h"

/***************************************Macros***********************************/

/***************************************Variables***********************************/

typedef enum
{
    TIMER_ONE_SHOT_MODE,
    TIMER_PERIODIC_MODE,
} SoftTimerMode_t;

typedef struct SoftTimer
{
    uint32_t u32interval;
    SoftTimerMode_t mode;
    uint32_t u32Current;
    uint8_t u8Triggered;
    void (*handler)(struct SoftTimer *timer);
} SoftTimer_t;

/***************************************Functions***********************************/
void SoftTimer_Init(void);
void swtimer_register(uint8_t index, uint32_t interval, SoftTimerMode_t SoftTimerMode);
void swtimer_start(uint8_t index);
void swtimer_stop(uint8_t index);
uint8_t swtimer_isTriggered(uint8_t index);
void SoftTimer_Handler(void);

#endif
/* [] END OF swtimer.h */
